version 17.0
clear
set more off

cd "INSERT PATH TO WORKING DIRECTORY HERE"

use "PULSE_without_lockdown_data.dta", replace

egen HHID = group(SCRAM)

***				CREATE ENTRY WEIGHTS FOR PANEL DATA ANALYSIS 					***

bysort HHID: egen minweek_HH=min(WEEK) if HWEIGHT<. & HWEIGHT>0

bysort HHID (WEEK): g entryweight_HH=HWEIGHT if WEEK==minweek_HH

bysort HHID (WEEK): egen WEIGHT_HH=mean(entryweight_HH)

replace WEIGHT_HH=. if HWEIGHT==. 

compress

*** 		TIME VARIABLES: MONTH AND PHASE OF SURVEY					***

g month=. 
replace month=5 if inlist(WEEK, 1, 2, 3, 4, 5)
replace month=6 if inlist(WEEK, 6, 7, 8, 9)
replace month=7 if inlist(WEEK, 10, 11, 12)
replace month=8 if inlist(WEEK, 13)
replace month=9 if inlist(WEEK, 14, 15)
replace month=10 if inlist(WEEK, 16, 17)
replace month=11 if inlist(WEEK, 18, 19)
replace month=12 if inlist(WEEK, 20, 21)
replace month=13 if inlist(WEEK, 22, 23)
replace month=14 if inlist(WEEK, 24, 25)
replace month=15 if inlist(WEEK, 26, 27)
replace month=16 if inlist(WEEK, 28)
replace month=17 if inlist(WEEK, 29, 30)
replace month=18 if inlist(WEEK, 31, 32, 33)
replace month=19 if inlist(WEEK, 34)
replace month=20 if inlist(WEEK, 35, 36)
replace month=21 if inlist(WEEK, 37, 38)
replace month=22 if inlist(WEEK, 39)
replace month=23 if inlist(WEEK, 40)
replace month=24 if inlist(WEEK, 41)
replace month=25 if inlist(WEEK, 42)
replace month=26 if inlist(WEEK, 43)
replace month=27 if inlist(WEEK, 44)
replace month=28 if inlist(WEEK, 45)
replace month=29 if inlist(WEEK, 46)
replace month=30 if inlist(WEEK, 47)
replace month=31 if inlist(WEEK, 48)
replace month=32 if inlist(WEEK, 49)
replace month=33 if inlist(WEEK, 50)
replace month=34 if inlist(WEEK, 51)
replace month=35 if inlist(WEEK, 52)
replace month=36 if inlist(WEEK, 53)
replace month=37 if inlist(WEEK, 54)
replace month=38 if inlist(WEEK, 55)
replace month=39 if inlist(WEEK, 56)
replace month=40 if inlist(WEEK, 57)

g year=. 
replace year=2020 if inlist(month, 5, 6, 7, 8, 9, 10, 11, 12)
replace year=2021 if inlist(month, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23)
replace year=2022 if inlist(month, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35)
replace year=2023 if inlist(month, 36, 37, 38, 39, 40)

label define MONTH 5 "May 2020" 6 "June 2020" 7 " July 2020" 8 "August 2020" 9 "September 2020" 10 "October 2020" 11 "November 2020" 12 "December 2020" 13 "January 2021" 14 "February 2021" 15 "March 2021" 16 "April 2021" 17 "May 2021" 18 "June 2021" 19 "July 2021" 20 "August 2021" 21 "September 2021" 22 "October 2021" 23 "December 2021" 24 "January 2022" 25 "February 2022" 26 "March 2022" 27 "April 2022" 28 "May 2022" 29 "June 2022" 30 "July 2022" 31 "August 2022" 32 "September 2022" 33 "October 2022" 34 "November 2022" 35 "December 2022" 36 "January 2023" 37 "February 2023" 38 "March 2023" 39 "April 2023" 40 "May 2023"
label values month MONTH
label variable month "MONTH"

g PWEIGHTM=0
replace PWEIGHTM=PWEIGHT if inlist(month, 8, 16, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40)
replace PWEIGHTM=PWEIGHT/2 if inlist(month, 9, 10, 11, 12, 13, 14, 15)
replace PWEIGHTM=PWEIGHT/3 if inlist(month, 7, 18)
replace PWEIGHTM=PWEIGHT/4 if inlist(month, 6)
replace PWEIGHTM=PWEIGHT/5 if inlist(month, 5)
label variable PWEIGHTM "adjust weights for multiple weeks in a month, only for monthly levels"

*** 					DEMOGRAPHIC VARIABLES									***
*** 	IMPORTANT: PUBLIC USE DATA DEFINE RACE/ETHNICITY MUTUALLY EXCLUSIVE 	***

label define rhispanic 1 "non-hispanic" 2 "hispanic"
label values RHISPANIC rhispanic
label variable RHISPANIC "hispanic origin" 

label define race 1 "white, alone" 2 "black, alone" 3 "asian, alone" 4 "other races, multiple"
label values RRACE race 
label variable RRACE "race"

g RACE=0
replace RACE=1 if RRACE==1 & RHISPANIC==1
replace RACE=2 if RRACE==2 & RHISPANIC==1
replace RACE=3 if RRACE==3 & RHISPANIC==1
replace RACE=4 if RRACE==4 & RHISPANIC==1

label values RACE race 
label variable RACE "race, not hispanic"

g RACEETH=0
replace RACEETH=1 if RRACE==1 & RHISPANIC==1
replace RACEETH=2 if RRACE==2 & RHISPANIC==1
replace RACEETH=3 if RRACE==3 & RHISPANIC==1
replace RACEETH=4 if RRACE==4 & RHISPANIC==1
replace RACEETH=5 if RHISPANIC==2

label define raceeth 1 "white, alone" 2 "black, alone" 3 "asian, alone" 4 "other races, multiple" 5 "Hispanic"
label values RACEETH raceeth 
label variable RACEETH "race and ethnicity, mutually exclusive"

g RACEETH2=0
replace RACEETH2=1 if RRACE==3 & RHISPANIC==1
replace RACEETH2=2 if RRACE==2 & RHISPANIC==1
replace RACEETH2=3 if RHISPANIC==2
replace RACEETH2=4 if RRACE==4 & RHISPANIC==1
replace RACEETH2=5 if RRACE==1 & RHISPANIC==1

label define raceeth2 1 "Asian, alone" 2 "Black, alone" 3 "Latino/Hispanic" 4 "Other/multiple races" 5 "White, alone"
label values RACEETH2 raceeth2 
label variable RACEETH2 "race/ethnicity alphabetically, mutually exclusive"

g WHITE=(RACEETH==1 & RACEETH<.)
label define white 0 "nonwhite or Latinx" 1 "white, alone"
label values WHITE white
label variable WHITE "indicator for white/nonwhite"

g BLACK=(RACEETH==2 & RACEETH<.)
label define black 0 "not Black" 1 "Black, alone"
label values BLACK black

g ASIAN=(RACEETH==3 & RACEETH<.)
label define asian 0 "non-Asian" 1 "Asian, alone"
label values ASIAN asian

g OTHER=(RACEETH==4 & RACEETH<.)
label define other 0 "not multiple/other races" 1 "other/multiple races"
label values OTHER other

g HISPANIC=(RACEETH==5 & RACEETH<.)
label define hispanic 0 "not Hispanic/Latinx" 1 "Hispanic/Latinx"
label values HISPANIC hispanic

g AGE=.
replace AGE=year-TBIRTH_YEAR

g YOLD=(AGE>=50)
label define yold 0 "younger than 50" 1 "50+"
label values YOLD yold
label variable YOLD "indicator for young/old, broken down at age 50"

g YOLD55=(AGE>=55)
label define age 0 "younger than 55 yrs" 1 "55+"
label values YOLD55 age
label variable YOLD55 "indicator for 55+"

g age10year=0
replace age10year=1 if AGE<25
replace age10year=2 if AGE>=25 & AGE<35
replace age10year=3 if AGE>=35 & AGE<45
replace age10year=4 if AGE>=45 & AGE<55
replace age10year=5 if AGE>=55 & AGE<65
replace age10year=6 if AGE>=65

label define agegroup 1 "less than 25" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+"
label values age10year agegroup
label variable age10year "10-year age groups"

g agegrp=0
replace agegrp=1 if AGE<25
replace agegrp=2 if AGE>=25 & AGE<=54
replace agegrp=3 if AGE>=55 & AGE<=64
replace agegrp=4 if AGE>=65

label define agegrouping 1 "less than 25" 2 "25-54" 3 "55-64" 4 "65+"
label values agegrp agegrouping
label variable agegrp "broad age groups"

g EDUC=0 if EEDUC>=1 & EEDUC<=7
replace EDUC=1 if EEDUC>=1 & EEDUC<=2
replace EDUC=2 if EEDUC==3
replace EDUC=3 if EEDUC>=4 & EEDUC<=5
replace EDUC=4 if EEDUC>=6 & EEDUC<=7

label define educ 0 "n.a." 1 "no h.s." 2 "h.s." 3 " some college" 4 "college"
label values EDUC educ
label variable EDUC "educational attainment"

g COLLEGE=0 if EEDUC>=1 & EEDUC<=7
replace COLLEGE=1 if EDUC==4

g NOHS=0 if EEDUC>=1 & EEDUC<=7
replace NOHS=1 if EDUC==1

g HS=0 if EEDUC>=1 & EEDUC<=7
replace HS=1 if EDUC==2

g SC=0 if EEDUC>=1 & EEDUC<=7
replace SC=1 if EDUC==3

label variable COLLEGE "indicator for at least college"

g MARRIED=0 if MS>0 & MS<.
replace MARRIED=1 if MS==1
replace MARRIED=2 if MS>=2 & MS<=4
replace MARRIED=3 if MS==5

label define married 0 "n.a." 1 "married" 2 "widowed, separated, divorced" 3 "never married"
label values MARRIED married
label variable MARRIED "marital status"

g married=0 if MS>0 & MS<.
replace married=1 if MS==1

label define gender 1 "men" 2 "women"
label values EGENDER gender
label variable EGENDER "gender"

g SINGLE=0 if MARRIED<.
replace SINGLE=1 if inlist(MARRIED, 2, 3)

g LGBTQ=0 if WEEK>=34 
replace LGBTQ=1 if EGENID_BIRTH~=GENID_DESCRIBE & inlist(EGENID_BIRTH, 1, 2) & inlist(GENID_DESCRIBE, 1, 2) | inlist(SEXUAL_ORIENTATION, 1, 3) | GENID_DESCRIBE==3
replace LGBTQ=2 if EGENID_BIRTH==GENID_DESCRIBE & SEXUAL_ORIENTATION==2
replace LGBTQ=3 if GENID_DESCRIBE==4 & inlist(SEXUAL_ORIENTATION, 2, 4, 5) | EGENID_BIRTH==GENID_DESCRIBE & inlist(SEXUAL_ORIENTATION, 4, 5)
label define lgbtq 0 "did not report" 1 "LGBTQ" 2 "straight" 3 "other"
label values LGBTQ lgbtq
label variable LGBTQ "CENSUS definition of LGBTQ"

g TRANSGENDER=0 if inlist(GENID_DESCRIBE, 1, 2, 3) & WEEK>=34
replace TRANSGENDER=1 if GENID_DESCRIBE==3 & WEEK>=34
label variable TRANSGENDER "transgender"

g FEMALE=0 if EGENDER>0 & EGENDER<. | inlist(GENID_DESCRIBE, 1, 2)
replace FEMALE=1 if EGENDER==2 | GENID_DESCRIBE==2 
label variable FEMALE "women"

g fam_status=0
replace fam_status=1 if MARRIED==1 
replace fam_status=2 if inlist(MARRIED, 2, 3) & FEMALE==0
replace fam_status=3 if inlist(MARRIED, 2, 3) & FEMALE==1
label define fam 1 "married" 2 "single men" 3 "single women"
label values fam_status fam
label variable fam_status "marital status by gender"

g PARENT=(THHLD_NUMKID>0 & THHLD_NUMKID<.)
label variable PARENT "indicator for having minor children in HH"

g MOTHER=(PARENT==1 & FEMALE==1)
g FATHER=(PARENT==1 & FEMALE==0)
g BADHEALTH=0 if HLTHSTATUS>=1 & HLTHSTATUS<=5
replace BADHEALTH=1 if HLTHSTATUS>=4 & HLTHSTATUS<=5

label define health 0 "good health" 1 "fair/poor health"
label values BADHEALTH health
label variable BADHEALTH "indicator for being in poor/fair health"

g HEALTHINS=0 if HLTHINS1>0 | HLTHINS2>0 | HLTHINS3>0 | HLTHINS4>0 | HLTHINS5>0 | HLTHINS6>0 | HLTHINS7>0 | HLTHINS8>0 
replace HEALTHINS=1 if HLTHINS1==1 | HLTHINS2==1 | HLTHINS3==1 | HLTHINS4==1 | HLTHINS5==1 | HLTHINS6==1 | HLTHINS7==1 | HLTHINS8==1

label variable HEALTHINS "indicator for having any health insurance"

forvalues i = 1/8 {

g HEALTHINS`i'=0 if HLTHINS`i'>0
replace HEALTHINS`i'=1 if HLTHINS`i'==1

}

label variable HEALTHINS1 "employer sponsore health insurance"
label variable HEALTHINS2 "individual coverage"
label variable HEALTHINS3 "Medicare"
label variable HEALTHINS4 "Medicaid"
label variable HEALTHINS5 "TRICARE"
label variable HEALTHINS6 "VA"
label variable HEALTHINS7 "Indian Health Services"
label variable HEALTHINS8 "other health ins., n.e.c."

g TYPEHEALTHINS=0 if HLTHINS1>0 | HLTHINS2>0 | HLTHINS3>0 | HLTHINS4>0 | HLTHINS5>0 | HLTHINS6>0 | HLTHINS7>0 | HLTHINS8>0
replace TYPEHEALTHINS=8 if HEALTHINS8==1 | HEALTHINS7==1
replace TYPEHEALTHINS=6 if HEALTHINS6==1 | HEALTHINS5==1
replace TYPEHEALTHINS=4 if HEALTHINS4==1
replace TYPEHEALTHINS=3 if HEALTHINS3==1
replace TYPEHEALTHINS=2 if HEALTHINS2==1
replace TYPEHEALTHINS=1 if HEALTHINS1==1

label define typehealthins 0 "no insurance" 1 "employer sponsore health insurance" 2 "individual coverage"  3 "Medicare" 4 "Medicaid" 6 "TRICARE/VA" 8 "Indian Health Services or other HI"
label values TYPEHEALTHINS typehealthins
label variable TYPEHEALTHINS "type of health insurance"

*** 		MENTAL HEALTH QUESTIONS -- OWN DEFINITIONS 				***

g MENTALHLTH=0 if inlist(ANXIOUS, 1, 2, 3, 4) | inlist(WORRY, 1, 2, 3, 4) | inlist(INTEREST, 1, 2, 3, 4) | inlist(DOWN, 1, 2, 3, 4)
replace MENTALHLTH=1 if inlist(ANXIOUS, 3, 4) | inlist(WORRY, 3, 4 ) | inlist(INTEREST, 3, 4) | inlist(DOWN, 3, 4)
label variable MENTALHLTH "mental health indicator: at least one measure says most of the days"

*** 		BROADER DEFINITION OF MENTAL HEALTH ISSUES 				***

g MENTALHLTH2=0 if inlist(ANXIOUS, 1, 2, 3, 4) | inlist(WORRY, 1, 2, 3, 4) | inlist(INTEREST, 1, 2, 3, 4) | inlist(DOWN, 1, 2, 3, 4)
replace MENTALHLTH2=1 if inlist(ANXIOUS, 2, 3, 4) | inlist(WORRY, 2, 3, 4 ) | inlist(INTEREST, 2, 3, 4) | inlist(DOWN, 2, 3, 4)
label variable MENTALHLTH2 "mental health indicator: at least one measure says several days"

*** 		NARROWER DEFINITION OF MENTAL HEALTH ISSUES				***

g MENTALHLTH3=0 if inlist(ANXIOUS, 1, 2, 3, 4) | inlist(WORRY, 1, 2, 3, 4) | inlist(INTEREST, 1, 2, 3, 4) | inlist(DOWN, 1, 2, 3, 4)
replace MENTALHLTH3=1 if inlist(ANXIOUS, 4) | inlist(WORRY, 4 ) | inlist(INTEREST, 4) | inlist(DOWN, 4)
label variable MENTALHLTH3 "mental health indicator: at least one measure says all the time"

*** 		CATEGORIZATION OF MENTAL HEALTH BY FREQUENCY			***

g MENTALHLTH5=0 if inlist(ANXIOUS, 1, 2, 3, 4) | inlist(WORRY, 1, 2, 3, 4) | inlist(INTEREST, 1, 2, 3, 4) | inlist(DOWN, 1, 2, 3, 4)
replace MENTALHLTH5=1 if inlist(ANXIOUS, 2) | inlist(WORRY, 2) | inlist(INTEREST, 2) | inlist(DOWN, 2)
replace MENTALHLTH5=2 if ANXIOUS==3 | WORRY==3 | INTEREST==3 | DOWN==3
replace MENTALHLTH5=3 if ANXIOUS==4 | WORRY==4 | INTEREST==4 | DOWN==4
label define mentalhlth5 0 "not at all" 1 "several days" 2 "most days" 3 "all the time"
label values MENTALHLTH5 mentalhlth5
label variable MENTALHLTH5 "categorization of mental health frequency" 

*** 	REDEFINING SCORES FOR MENTAL HEALTH QUESTIONS TO MIRROR		***
*** 	CDC DEFINITIONS: https://www.cdc.gov/nchs/covid19/pulse/mental-health.htm ***

g ANXIOUS_CDC=0 if inlist(ANXIOUS, 1, 2, 3, 4)
replace ANXIOUS_CDC=1 if ANXIOUS==2
replace ANXIOUS_CDC=2 if ANXIOUS==3
replace ANXIOUS_CDC=3 if ANXIOUS==4

g WORRY_CDC=0 if inlist(WORRY, 1, 2, 3, 4)
replace WORRY_CDC=1 if WORRY==2
replace WORRY_CDC=2 if WORRY==3
replace WORRY_CDC=3 if WORRY==4

g INTEREST_CDC=0 if inlist(INTEREST, 1, 2, 3, 4)
replace INTEREST_CDC=1 if INTEREST==2
replace INTEREST_CDC=2 if INTEREST==3
replace INTEREST_CDC=3 if INTEREST==4

g DOWN_CDC=0 if inlist(DOWN, 1, 2, 3, 4)
replace DOWN_CDC=1 if DOWN==2
replace DOWN_CDC=2 if DOWN==3
replace DOWN_CDC=3 if DOWN==4

g DEPRESSIONSCORE=0 if INTEREST_CDC<. & DOWN_CDC<. 
replace DEPRESSIONSCORE=INTEREST_CDC+DOWN_CDC 
label variable DEPRESSIONSCORE "Combined PHQ-2, only for Rs with both Qs, CDC comparable"

g ANXIETYSCORE=0 if ANXIOUS_CDC<. & WORRY_CDC<.
replace ANXIETYSCORE=ANXIOUS_CDC+WORRY_CDC
label variable ANXIETYSCORE "combined GAD-2, only for Rs with both Qs, CDC comparable"

g DEPRESSED=0 if DEPRESSIONSCORE<.
replace DEPRESSED=1 if DEPRESSIONSCORE>=3 & DEPRESSIONSCORE<.
label variable DEPRESSED "Rs who are depressed"

g ANXIETYDISORDER=0 if ANXIETYSCORE<.
replace ANXIETYDISORDER=1 if ANXIETYSCORE>=3 & ANXIETYSCORE<.
label variable ANXIETYDISORDER "Rs who have anxiety disorder"

g MENTALHLTH_CDC=0 if DEPRESSED<. & ANXIETYDISORDER<.
replace MENTALHLTH_CDC=1 if DEPRESSED==1 | ANXIETYDISORDER==1 
label define mentalhlth_cdc 0 "no anxiety/depression" 1 "anxiety or depressive disorder"
label variable MENTALHLTH_CDC "Depression or anxiety disorder, CDC comparable"

***			DISABILITIES RECODED TO AVOID NON-RESPONSES				***

foreach disab in SEEING HEARING MOBILITY REMEMBERING {
    
g `disab'DIFF=0 if `disab'>=0 & `disab'<.
replace `disab'DIFF=1 if `disab'==1
replace `disab'DIFF=2 if `disab'==2
replace `disab'DIFF=3 if `disab'==3
replace `disab'DIFF=4 if `disab'==4

label define `disab'diff 0 "n.e.c." 1 "no difficulty" 2 "some difficulty" 3 "a lot of difficulty" 4 "cannot do at all"
label values `disab'DIFF `disab'diff
label variable `disab'DIFF "difficulty with `disab'"

g `disab'DIFF2=0 if `disab'>=0 & `disab'<.
replace `disab'DIFF2=1 if `disab'==1
replace `disab'DIFF2=2 if `disab'==2
replace `disab'DIFF2=3 if inlist(`disab', 3, 4) 

label define `disab'diff2 0 "n.e.c." 1 "no difficulty" 2 "some difficulty" 3 "lot of difficulty/can't dpo at all"
label values `disab'DIFF2 `disab'diff2
label variable `disab'DIFF2 "difficulty with `disab', 3 cat."

}

egen DISABSCORE=rowtotal(HEARINGDIFF SEEINGDIFF MOBILITYDIFF REMEMBERINGDIFF) 
g DISABILITY=(DISABSCORE>=8)
label define disability 0 "sum score less than 8" 1 "sum score 8+"
label values DISABILITY disability
label variable DISABILITY "has a score of at least 12 across 4 disabilities"

g DISABILITY2=0
replace DISABILITY2=1 if HEARINGDIFF2==3 | SEEINGDIFF2==3 | MOBILITYDIFF2==3 | REMEMBERINGDIFF2==3
label define disability2 0 "no ability with lot+ difficulty" 1 "at least one ability with lot+ difficulty"
label values DISABILITY2 disability2
label variable DISABILITY2 "lot of difficulty or can't do at least one ability"

*** 	CURRENT HOUSING TROUBLE MEASURES NOT AVAILABLE IN PHASE 2 			***

g CURRMORTGGTROUBLE=0 if TENURE==2 & MORTLMTH>0 & WEEK<=12 | TENURE==2 & MORTCUR>0 & WEEK>=13
replace CURRMORTGGTROUBLE=1 if TENURE==2 & MORTLMTH>=2 & MORTLMTH<=3 & WEEK<=12 | TENURE==2 & MORTCUR==2 & WEEK>=13
label variable CURRMORTGGTROUBLE "didn't pay/deferred mortgage this month"
label define mrtggtrouble 0 "paid mortgage" 1 "didn't pay/deferred/not current on mortgage"
label values CURRMORTGGTROUBLE mrtggtrouble

g CURRRENTTROUBLE=0 if TENURE==3 & MORTLMTH>0 & WEEK<=12 | RENTCUR>0 & TENURE==3 & WEEK>=13
replace CURRRENTTROUBLE=1 if TENURE==3 & MORTLMTH>=2 & MORTLMTH<=3 & WEEK<=12 | RENTCUR==2 & TENURE==3 & WEEK>=13
label variable CURRRENTTROUBLE "didn't pay/deferred/not current on rent"
label define renttrouble 0 "paid rent" 1 "didn't pay/deferred/not current on rent"
label values CURRRENTTROUBLE renttrouble

g CURRHOUSINGTROUBLE=0 if TENURE>0
replace CURRHOUSINGTROUBLE=1 if CURRMORTGGTROUBLE==1 & TENURE==2 | CURRRENTTROUBLE==1 & TENURE==3

label variable CURRHOUSINGTROUBLE "didn't pay/deferred rent/mortgage"
label define housingtrouble 0 "paid rent/mortgage" 1 "didn't pay/defer rent/mortgage"
label values CURRHOUSINGTROUBLE housingtrouble

g FUTMORTGGTROUBLE=0 if TENURE==2 & MORTCONF>0
replace FUTMORTGGTROUBLE=1 if TENURE==2 & MORTCONF>=1 & MORTCONF<=2 | TENURE==2 & MORTCONF==5
label variable FUTMORTGGTROUBLE "no/little confidence or defer future mortgage"

g FUTRENTTROUBLE=0 if TENURE==3 & MORTCONF>0
replace FUTRENTTROUBLE=1 if TENURE==3 & MORTCONF>=1 & MORTCONF<=2 | TENURE==3 & MORTCONF==5
label variable FUTRENTTROUBLE "no/little confidence or defer future rent"

g MORTTROUBLE=(CURRMORTGGTROUBLE==1 & TENURE==2 | FUTMORTGGTROUBLE & TENURE==2)

***			PHASE 2 QUESTIONS RELATE TO BEING CAUGHT UP ON RENT/MORTGAGE	***
***						OR FEARING EVICTION/FORECLOSURE						***

g CURRRENT=0 if RENTCUR>0 & RENTCUR<.
replace CURRRENT=1 if RENTCUR==2
label define currrent 0 "current on rent" 1 "not current on rent"
label values CURRRENT currrent 
label variable CURRRENT "indicator for not being current on rent"

g CURRMORT=0 if MORTCUR>0 & RENTCUR<.
replace CURRMORT=1 if MORTCUR==2
label define currmort 0 "current on mortgage" 1 "not current on mortgage"
label values CURRMORT currmort 
label variable CURRMORT "indicator for not being current on mortgage"

g CURRHOUSING=0 if CURRRENT<. | CURRMORT<.
replace CURRHOUSING=1 if CURRRENT==1 | CURRMORT==1 
label define currhousing 0 "current on housing payments" 1 "not current on housing payments"
label values CURRHOUSING currhousing
label variable CURRHOUSING "indicator for not being current on housing payments"

g LKLYEVICT=0 if EVICT>0 & EVICT<.
replace LKLYEVICT=1 if inlist(EVICT, 1, 2, 3)
label define evict_label 0 "not likely" 1 "somewhat, very, extremely likely"
label values LKLYEVICT evict_label
label variable LKLYEVICT "indicator for likely eviction"

g GOTRENTASSIST=0 if inlist(RENTASSIST, 1, 2, 3, 4)
replace GOTRENTASSIST=1 if RENTASSIST==1
replace GOTRENTASSIST=2 if RENTASSIST==2
replace GOTRENTASSIST=3 if RENTASSIST==3
replace GOTRENTASSIST=4 if RENTASSIST==4
label define rentassist 0 "n.e.c" 1 "applied & received" 2 "applied & waiting" 3 "applied & denied" 4 "did not apply"
label values RENTASSIST rentassist
label variable GOTRENTASSIST "status of rental assistance"

g LKLYFORECLOSE=0 if FORCLOSE>0 & FORCLOSE<.
replace LKLYFORECLOSE=1 if inlist(FORCLOSE, 1, 2, 3)
label define foreclose_label 0 "not likely" 1 "somewhat, very, extremely likely"
label values LKLYFORECLOSE foreclose_label
label variable LKLYFORECLOSE "indicator for likely foreclosure"

g LKLYHOUSELOSS=0 if LKLYEVICT<. | LKLYFORECLOSE<.
replace LKLYHOUSELOSS=1 if LKLYEVICT==1 | LKLYFORECLOSE==1
label define houseloss_label 0 "not likely" 1 "somewhat, very, extremely likely"
label values LKLYHOUSELOSS houseloss_label
label variable LKLYHOUSELOSS "indicator for likely housing loss"

g EDUCCOMP=0 if ENROLL1==1 & COMPAVAIL>0
replace EDUCCOMP=1 if ENROLL1==1 & COMPAVAIL>=3 & COMPAVAIL<=5

label variable EDUCCOMP "computer sometimes/rarely/never available"

g EDUCINTNT=0 if ENROLL1==1 & INTRNTAVAIL>0
replace EDUCINTNT=1 if ENROLL1==1 & INTRNTAVAIL>=3 & INTRNTAVAIL<=5

label variable EDUCINTNT "internet sometimes/rarely/never available"

label define income -99 "not responded" -88 "seen/not selected" 1 "<$25,000" 2 "$25,000-$34,999" 3 "$35,000-$49,999" 4 "$50,000-$74,999" 5 "$75,000-$99,999" 6 "$100,000-$149,999" 7 "$150,000-$199,999" 8 "$200,000+"
label values INCOME income

g INCCAT=0 if INCOME>0 
replace INCCAT=1 if INCOME==1
replace INCCAT=2 if INCOME==2
replace INCCAT=3 if INCOME==3
replace INCCAT=4 if INCOME==4
replace INCCAT=5 if INCOME==5
replace INCCAT=6 if INCOME==6
replace INCCAT=7 if INCOME==7 
replace INCCAT=8 if INCOME==8
label define inccat 0 "n.e.c." 1 "<$25,000" 2 "$25,000-$34,999" 3 "$35,000-$49,999" 4 "$50,000-$74,999" 5 "$75,000-$99,999" 6 "$100,000-$149,999" 7 "$150,000-$199,999" 8 "$200,000+"
label values INCCAT inccat

g INCCAT2=0 if INCOME>0 
replace INCCAT2=1 if inlist(INCOME, 1, 2) 
replace INCCAT2=2 if inlist(INCOME, 3, 4, 5) 
replace INCCAT2=3 if inlist(INCOME, 6, 7) 
replace INCCAT2=4 if INCOME==8
label define inccat2 0 "n.e.c." 1 "<$34,999" 2 "$35,000-99,999" 3 "$100,000-$199,999" 4 "$200,000+"
label values INCCAT2 inccat2

g LOWINC=(INCCAT2==1)
g MIDINC=(INCCAT2==2)
g UPMIDINC=(INCCAT2==3)
g HIGHINC=(INCCAT2==4)

label define working 1 "yes" 2 "no" -99 "not selected" -88 "not responded"
label values ANYWORK working
label variable ANYWORK "working"

g GOVTJOB=(KINDWORK==1)
g PRIVCO=(KINDWORK==2)
g NPCO=(KINDWORK==3)
g SELFEMP=(KINDWORK==4)
g FAMBUS=(KINDWORK==5)

g TELEWORK=0 if inlist(ACTIVITY2, 1, 2) | inlist(TWDAYS, 1, 2, 3, 4) & WEEK>=46
replace TELEWORK=1 if ACTIVITY2==1 | inlist(TWDAYS, 1, 2, 3) & WEEK>=46
label variable TELEWORK "engaged in telework in past 7 days"

g TELEWORKDAYS=0 if ANYWORK==1 & inlist(TWDAYS, 1, 2, 3, 4) & inlist(WEEK, 49, 50, 51, 52, 53, 54, 55, 56, 57)
replace TELEWORKDAYS=1 if ANYWORK==1 & TWDAYS_RESP==1
replace TELEWORKDAYS=2 if ANYWORK==1 & TWDAYS_RESP==2
replace TELEWORKDAYS=3 if ANYWORK==1 & TWDAYS_RESP==3

label define twdays 0 "no days" 1 "1-2 days" 2 "3-4 days" 3 "5+ days" 
label values TELEWORKDAYS twdays
label variable TELEWORKDAYS "telework days for respondent"

***		INCOME CUTOFFS BY MARITAL STATUS FOR RELIEF NEGOTIATIONS		***

g INCCUTOFF=0 if INCCAT<.
replace INCCUTOFF=1 if INCCAT==4 & inlist(MARRIED, 2, 3) | INCCAT==6 & MARRIED==1
replace INCCUTOFF=2 if INCCAT>5 & INCCAT<. & inlist(MARRIED, 2, 3) | INCCAT>6 & INCCAT<. & MARRIED==1
label define inccutoff 0 "below new cutoff" 1 "between old and new cutoff" 2 "above old cutoff"
label values INCCUTOFF inccutoff
label variable INCCUTOFF "income cutoff categories for relief negotiations"

g NOWORK=0 if ANYWORK>0
replace NOWORK=1 if ANYWORK==2
label define nowork 0 "working" 1 "not working"
label values NOWORK nowork
label variable NOWORK "not working"

g WORKING=0 if ANYWORK>0 
replace WORKING=1 if ANYWORK==1
label define haswork 0 "not working" 1 "working"
label values WORKING haswork
label variable WORKING "working"

*** 	CLEAR BREAK IN DATA, POSSIBLE BECAUSE OF REPHRASED QUESTION 	***

g LOSTJOB=0 if WRKLOSS>0 & WRKLOSS<. | WRKLOSSRV>0 & WRKLOSSRV<. 
replace LOSTJOB=1 if WRKLOSS==1 | WRKLOSSRV==1

g EXPJOBLOSS=0 if EXPCTLOSS>0
replace EXPJOBLOSS=1 if EXPCTLOSS==1

label define emptype -99 "not selected" -88 "missing" 1 "government" 2 "private company" 3 "nonprofit" 4 "self-employment" 5 "working in family business"
label values KINDWORK emptype
label variable KINDWORK "type of work"

g PUBPRIV=0 if inlist(KINDWORK, 1, 2, 3)
replace PUBPRIV=1 if KINDWORK==1
label variable PUBPRIV "govt ee=1, WS only"

g SMEEMP=0 if KINDWORK>0
replace SMEEMP=1 if KINDWORK>=4 & KINDWORK<=5

g RETIRED=0 if inlist(ANYWORK, 1, 2)
replace RETIRED=1 if RSNNOWRK==7 | RSNNOWRKRV==7 

g NEARRETIREE=0 if AGE<. & RETIRED<.
replace NEARRETIREE=1 if AGE>=55 & AGE<=69 & RETIRED==0

g RECENTRETIREE=0 if AGE<. & RETIRED<. 
replace RECENTRETIREE=1 if AGE>=55 & AGE<=69 & RETIRED==1

g RETSTATUS=0 if AGE<. & RETIRED<. & AGE>=55 & AGE<=69
replace RETSTATUS=1 if NEARRETIREE==1
replace RETSTATUS=2 if RECENTRETIREE==1
label define retstatus 0 "n.e.c." 1 "near retirees" 2 "recent retirees"
label values RETSTATUS retstatus
label variable RETSTATUS "retirement status"

*** 	HEALTH RELATED ANSWERS CHANGED IN PHASE 3.1 (WEEK 28); SHARES		***
***		ARE NOT COMPARABLE OVER TIME, CONSIDER EACH PHASE SEPARATELTLY		***

g RSNNOTWORK1=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK1=1 if RSNNOWRK==1 | RSNNOWRKRV==1
label variable RSNNOTWORK1 "didn't want to be employed"

g RSNNOTWORK2=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK2=1 if inlist(RSNNOWRK, 2, 3) | RSNNOWRKRV==2
label variable RSNNOTWORK2 "not working b/c sick/caring for someone with COVID" 

g RSNNOTWORK3=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK3=1 if RSNNOWRK==4 | RSNNOWRKRV==3
label variable RSNNOTWORK3 "not working b/c childcare"

g RSNNOTWORK4=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK4=1 if RSNNOWRK==5 | RSNNOWRKRV==4
label variable RSNNOTWORK4 "not working b/c adult care"

g RSNNOTWORK5=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK5=1 if RSNNOWRK==13 | RSNNOWRKRV==5
label variable RSNNOTWORK5 "not working b/c afraid of COVID"
	
g RSNNOTWORK6=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK6=1 if RSNNOWRK==6 | RSNNOWRKRV==6
label variable RSNNOTWORK6 "not working b/c sick/disabled"

g RSNNOTWORK7=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK7=1 if RSNNOWRK==7 | RSNNOWRKRV==7
label variable RSNNOTWORK7 "retired"

g RSNNOTWORK8=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK8=1 if inlist(RSNNOWRK, 8, 9) | RSNNOWRKRV==8
label variable RSNNOTWORK8 "laid off/furloughed due to COVID"

g RSNNOTWORK9=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK9=1 if RSNNOWRK==10 | RSNNOWRKRV==9
label variable RSNNOTWORK9 "employer closed temporarily due to COVID"

g RSNNOTWORK10=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK10=1 if RSNNOWRK==11 | RSNNOWRKRV==10
label variable RSNNOTWORK10 "employer went out of business due to COVID"

g RSNNOTWORK11=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK11=1 if RSNNOWRKRV==11
label variable RSNNOTWORK11 "not working b/c no transportation"

g RSNNOTWORK12=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace RSNNOTWORK12=1 if RSNNOWRKRV==12 | RSNNOWRK==12
label variable RSNNOTWORK12 "not working b/c other reason"

g CAREGIVENOWORK=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<.
replace CAREGIVENOWORK=1 if inlist(RSNNOWRK, 3, 4, 5) | inlist(RSNNOWRKRV, 2, 3, 4)
label variable CAREGIVENOWORK "not working to care for child, adult, someone with COVID"

g CAREGIVENOWORK2=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<.
replace CAREGIVENOWORK2=1 if inlist(RSNNOWRK, 4, 5) | inlist(RSNNOWRKRV, 3, 4)
label variable CAREGIVENOWORK2 "not working to care for child/adult"

g HEALTHNOWORK=0 if RSNNOWRK<. & RSNNOWRK>0 | RSNNOWRKRV>0 & RSNNOWRKRV<.
replace HEALTHNOWORK=1 if inlist(RSNNOWRK, 2, 6) | inlist(RSNNOWRKRV, 2, 5, 6)
label variable HEALTHNOWORK "not working for health reasons"

g BUSNOWORK=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace BUSNOWORK=1 if RSNNOWRK>=8 & RSNNOWRK<=11 | inlist(RSNNOWRKRV, 8, 9, 10)
label variable BUSNOWORK "not working because of business reasons"

g CHILDCARENOWORK=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace CHILDCARENOWORK=1 if inlist(RSNNOWRK, 4) | inlist(RSNNOWRKRV, 3)
label variable CHILDCARENOWORK "not working to care for children"

g ADULTCARENOWORK=0 if RSNNOWRK>0 & RSNNOWRK<. | RSNNOWRKRV>0 & RSNNOWRKRV<. 
replace ADULTCARENOWORK=1 if inlist(RSNNOWRK, 5) | inlist(RSNNOWRKRV, 4)
label variable ADULTCARENOWORK "not working to care for elderly"

g NOTWORK=0 if RSNNOWRK<. | RSNNOWRKRV<.
replace NOTWORK=1 if BUSNOWORK==1
replace NOTWORK=2 if CAREGIVENOWORK2==1
replace NOTWORK=3 if HEALTHNOWORK==1
replace NOTWORK=4 if RETIRED==1
replace NOTWORK=5 if RSNNOTWORK1==1
label define notwork 0 "n.e.c." 1 "bus. reason for not working" 2 "caregiving reasons for not working" 3 "health reasons for not working" 4 "retired" 5 "didn't want to be employed"
label values NOTWORK notwork
label variable NOTWORK "combined reasons for not working"

*******************************************************************************
***		APPROXIMATION OF UNEMPLOYMENT/LABOR FORCE WITH RSNNOWORK			***
*******************************************************************************

g EMPSTATUS=0 if inlist(ANYWORK, 1, 2) 
replace EMPSTATUS=1 if ANYWORK==1 						
replace EMPSTATUS=2 if ANYWORK==2 & BUSNOWORK==1
replace EMPSTATUS=3 if ANYWORK==2 & RSNNOTWORK7==1 
replace EMPSTATUS=4 if ANYWORK==2 & CAREGIVENOWORK2==1
label define empstatus 0 "out of labor force" 1 "employed" 2 "not working b/c bus cond" 3 "retired" 4 "not working b/c caregiving"
label values EMPSTATUS empstatus
label variable EMPSTATUS "labor force status"

label define unemppay -99 "not selected" -88 "not responded" 1 "yes, paid leave" 2 "yes, full pay/no leave" 3 "yes, partial pay" 4 "no pay"
label values UNEMPPAY unemppay 
label variable UNEMPPAY "receiving pay for not working"

*** LOOK BACK PERIOD FOR UI BENEFITS CHANGED FROM WEEK 27 TO WEEK 28 		***

g UIBENEFIT=0 if UI_APPLY>0 & UI_APPLY<.  
replace UIBENEFIT=1 if UI_RECV==1 & UI_APPLY==1 | UI_RECVRV==1 & UI_APPLYRV==1
replace UIBENEFIT=2 if UI_APPLY==1 & UI_RECV==2 | UI_RECVRV==2 & UI_APPLYRV==2
label define uibenefit 0 "not applied/received" 1 "applied & received" 2 "applied & not received"
label values UIBENEFIT uibenefit
label variable UIBENEFIT "UI benefit application and receipt"

*** 	WORDING OF UI RECEIPT QUESTION CHANGED WITH WEEK 28 		***
*** 	VARIABLE IS NOT COMPARABLE ACROSS WEEKS						***
*** 	QUESTION BEFORE WEEK 28 SEEMS TO HAVE BEEN ASKED OF PEOPLE 	***
*** 	WHO APPLIED, BUT DATA DICTIONARY SAYS IT WAS ASKED OF ALL 	***
*** 	PEOPLE -- ONLY USE AFTER WEEK 27 							***
*** 	UI CHANGES TOO MASSIVE OVER COURSE OF 2021 TO MAKE 			***
*** 	INTERTEMPORAL COMPARISONS USEFL, ONLY USE THROUGH WEEK 33	***

g UIRECEIPT=0 if UI_RECVRV>0 & UI_RECVRV<. & inlist(WEEK, 28, 29, 30, 31, 32, 33)
replace UIRECEIPT=1 if UI_RECVRV==1 & inlist(WEEK, 28, 29, 30, 31, 32, 33)
label variable UIRECEIPT "received UI in the past"
label define uireceipt 0 "no UI benefits" 1 "got UI benefits in the past"
label values UIRECEIPT uireceipt

*** 	CURRENT RECEIPT ASKED OF ONLY PEOPLE WHO HAD UI AT SOME 	***
*** 	POINT IN THE PAST, DATING BACK TO JANUARY 2021				***

g UIRECEIPTNOW=0 if UI_RECVNOW>0 & UI_RECVNOW<. & inlist(WEEK, 28, 29, 30, 31, 32, 33)
replace UIRECEIPTNOW=1 if UI_RECVNOW==1
label define uireceiptnow 0 "no UI benefits" 1 "UI benefits in past 7 days"
label values UIRECEIPTNOW uireceiptnow
label variable UIRECEIPTNOW "received UI benefits in past 7 days"

label define currfoodsufficiency -99 "not selected" -88 "not reported" 1 "enough to eat" 2 "not always the kinds wanted to eat" 3 "sometimes not enough to eat" 4 "often not enough to eat"
label values CURFOODSUF currfoodsufficiency
label variable CURFOODSUF "current food sufficiency"

*** 				FOOD INSECURITY QUESTIONS 							***

g FOODINSUFFICIENCY=0 if CURFOODSUF>=0 & CURFOODSUF<.
replace FOODINSUFFICIENCY=1 if inlist(CURFOODSUF, 2, 3, 4)
label variable FOODINSUFFICIENCY "Not right food, sometimes/often not enough to eat" 

g FOODINSUFFICIENCY2=0 if CURFOODSUF>=0 & CURFOODSUF<.
replace FOODINSUFFICIENCY2=1 if inlist(CURFOODSUF, 3, 4)
label define foodinsuf2 0 "enough/enough but not right" 1 "sometimes/often not enough"
label variable FOODINSUFFICIENCY2 "sometimes/often not enough to eat" 
label values FOODINSUFFICIENCY2 foodinsuf2

g FOODINSUFFDETAIL=0 if CURFOODSUF>=0 & CURFOODSUF<.
replace FOODINSUFFDETAIL=1 if CURFOODSUF==1
replace FOODINSUFFDETAIL=2 if CURFOODSUF==2
replace FOODINSUFFDETAIL=3 if CURFOODSUF==3
replace FOODINSUFFDETAIL=4 if CURFOODSUF==4
label define foodinsufdetail 0 "n.e.c." 1 "enough to eat" 2 "enough but not always what is wanted" 3 "sometimes not enough to eat" 4 "often not enough to eat"
label values FOODINSUFFDETAIL foodinsufdetail
label variable FOODINSUFFDETAIL "detailed food insecurity"

g KIDNOTEAT=0 if CHILDFOOD>0 & CHILDFOOD<. 
replace KIDNOTEAT=1 if inlist(CHILDFOOD, 1, 2)
label variable KIDNOTEAT "Kids sometimes/often don't eat enough b/c can't afford"

foreach num in 1 2 3 4 {
g RSNINSFFOOD`num'=0 if FOODRSNRV1==1 | FOODRSNRV2==1 | FOODRSNRV3==1
replace RSNINSFFOOD`num'=1 if FOODRSNRV`num'==1

}

label variable RSNINSFFOOD1 "couldn't afford food"
label variable RSNINSFFOOD2 "couldn't get out to buy food"
label variable RSNINSFFOOD3 "safety concerns or delivery" 
label variable RSNINSFFOOD4 "no reason"

g GOTFREEFOOD=0 if inlist(FREEFOOD, 1, 2)
replace GOTFREEFOOD=1 if FREEFOOD==1
label variable GOTFREEFOOD "got free food"

foreach num in 1 2 3 4 {

g SCHOOLFOOD`num'=0 if SCHLFDHLP1==1 | SCHLFDHLP2==1 | SCHLFDHLP3==1 | SCHLFDHLP4==1 | NOSCHLFDHLP==1
replace SCHOOLFOOD`num'=1 if SCHLFDHLP`num'==1

} 

label variable SCHOOLFOOD1 "pick up food at school"
label variable SCHOOLFOOD2 "got EBT"
label variable SCHOOLFOOD3 "eat food at school"
label variable SCHOOLFOOD4 "have meals delivered"

g SNAP=0 if inlist(SNAP_YN, 1, 2)
replace SNAP=1 if SNAP_YN==1 
label variable SNAP "got SNAP"

g HORENT=0 if TENURE>=1 & TENURE<=4
replace HORENT=1 if TENURE>=1 & TENURE<=2
replace HORENT=2 if TENURE>=3 & TENURE<=4
label define renter 0 "n.e.c." 1 "homeowner" 2 "renter"
label values HORENT renter
label variable HORENT "homeowner/renter"

g HHOUSES=0 if TENURE>=1 & TENURE<=4
replace HHOUSES=1 if HORENT==1
label define homeowner 0 "renter" 1 "homeowner"
label values HHOUSES homeowner
label variable HHOUSES "homeowner"

*** 		CODING VARIABLES FOR STATE-BY-STATE ANALYSIS				***

g stategroups=0
replace stategroups=1 if inlist(EST_ST, 04, 06, 12, 48) 					//reversing
replace stategroups=4 if inlist(EST_ST, 02, 19, 20, 28, 29, 33, 40, 46, 55 )		//reopened
replace stategroups=2 if inlist(EST_ST, 01, 05, 10, 16, 22, 26, 32,35, 37, 41, 53, 56 )					//pausing
replace stategroups=3 if inlist(EST_ST, 08, 09, 11, 13, 15, 17, 18, 21, 23, 24, 25, 27, 30, 31, 34, 36, 38, 39, 42, 44, 45, 47, 49, 50, 51, 54) //reopening

label define SG 0 "n.e.c." 1 "reversing by end of June" 4 "reopened by end of June" 2 "pausing by end of June" 3 "reopening by end of June"
label values stategroups SG
label variable stategroups "reopening status by end of June per NYT"

g REDBLUESTATE=0
replace REDBLUESTATE=1 if inlist(EST_ST, 1, 2, 5, 13, 16, 18, 19, 20, 21, 22, 28, 29, 30, 31, 38, 39, 40, 45, 46, 47, 48, 49, 54, 56)
replace REDBLUESTATE=2 if inlist(EST_ST, 6, 9, 10, 11, 15, 17, 24, 25, 26, 27, 34, 36, 41, 42, 44, 50, 53, 55)
replace REDBLUESTATE=3 if inlist(EST_ST, 4, 8, 19, 23, 32, 33, 35, 37, 51)
label define redbluestate 0 "n.e.c." 1 "red" 2 "blue" 3 "purple"
label values REDBLUESTATE redbluestate
label var REDBLUESTATE "indicator for states' political leanings"

label define state_lbl  1 "Alabama" 2 "Alaska" 4 "Arizona" 5 "Arkansas" 6 "California" 8 "Colorado" 9 "Connecticut" 10 "Delaware" 11 "District of Columbia" 12 "Florida" 13 "Georgia" 15 "Hawaii" 16 "Idaho" 17 "Illinois" 18 "Indiana" 19 "Iowa" 20 "Kansas" 21 "Kentucky" 22 "Louisiana" 23 "Maine" 24 "Maryland" 25 "Massachusetts" 26 "Michigan" 27 "Minnesota" 28 "Mississippi" 29 "Missouri" 30 "Montana" 31 "Nebraska" 32 "Nevada" 33 "New Hampshire" 34 "New Jersey" 35 "New Mexico" 36 "New York" 37 "North Carolina" 38 "North Dakota" 39 "Ohio" 40 "Oklahoma" 41 "Oregon" 42 "Pennsylvania" 44 "Rhode Island" 45 "South Carolina" 46 "South Dakota" 47 "Tennessee" 48 "Texas" 49 "Utah" 50 "Vermont" 51 "Virginia" 53 "Washington" 54 "West Virginia" 55 "Wisconsin" 56 "Wyoming"
label values EST_ST state_lbl
label variable EST_ST "state"

g CENREG=0
replace CENREG=1 if inlist(EST_ST, 09, 23, 25, 33, 34, 36, 42, 44, 50)
replace CENREG=2 if inlist(EST_ST, 1, 5, 10, 11, 12, 13, 21, 22, 24, 28, 37, 40, 45, 47, 48, 51, 54)
replace CENREG=3 if inlist(EST_ST, 17, 18, 19, 20, 26, 27, 29, 31, 38, 39, 46, 55)
replace CENREG=4 if inlist(EST_ST, 02, 04, 06, 08, 15, 16, 30, 32, 35, 41, 49, 53, 56)
label define cenreg 1 "Northeast" 2 "South" 3 "Midwest" 4 "West"
label values CENREG cenreg
label variable CENREG "Census Regions"

*** 		ADJUST WEIGHTS FOR MULTIPLE WEEKS IN A MONTH, ONLY NECESSARY	***
*** 	WHEN CALCULATING TOTALS BY MONTH									***

g monthweight=. 
replace monthweight=PWEIGHT if inlist(month, 8, 16, 19, 22, 23)
replace monthweight=PWEIGHT/2 if inlist(month, 9, 10, 11, 12, 13, 14, 15, 17, 20, 21)
replace monthweight=PWEIGHT/3 if inlist(month, 7, 18)
replace monthweight=PWEIGHT/4 if inlist(month, 6)
replace monthweight=PWEIGHT/5 if inlist(WEEK, 5)

*** 			FINANCIAL STRESSES										***

g DIFFEXPNS=0 if EXPNS_DIF>0 & EXPNS_DIF<. & WEEK>12
replace DIFFEXPNS=1 if inlist(EXPNS_DIF, 3, 4)
label define diffexp 0 "not at all/little difficult" 1 "somewhat/very difficult"
label values DIFFEXPNS diffexp
label variable DIFFEXPNS "difficulty paying expenses"

g TROUBLEPAY=0 if DIFFEXPNS<. & WEEK>12 | CURRRENT<. & WEEK>12 | CURRMORT<. & WEEK>12 
replace TROUBLEPAY=1 if DIFFEXPNS==1 & WEEK>12 | CURRRENT==1 & WEEK>12 | CURRMORT==1 & WEEK>12
label define troublepay 0 "can pay all bills/rent/mortgage" 1 "can't pay all bills/rent/mortgage"
label values TROUBLEPAY troublepay
label variable TROUBLEPAY "trouble paying bills, rent or mortgage"

g FINHARDSHIP=0 if TROUBLEPAY<. & WEEK>12 | CURRRENT<. & WEEK>12 | CURRMORT<. & WEEK>12 | FOODINSUFFICIENCY<. & WEEK>12
replace FINHARDSHIP=1 if TROUBLEPAY==1 & WEEK>12 | CURRRENT==1 & WEEK>12 | CURRMORT==1 & WEEK>12 | FOODINSUFFICIENCY2==1 & WEEK>12
label define finhardship 0 "no financial difficulties" 1 "prob. w/bills/rent/mortgg/food"
label values FINHARDSHIP finhardship
label variable FINHARDSHIP "prob. paying bills/rent/mortgage/food"

*** 		SPENDING AND TRANSPORTATION CHANGES							***

forvalues i=1/12 {

g SPENDCHG`i'=0 if CHNGHOW1>0 & CHNGHOW1<. | CHNGHOW2>0 & CHNGHOW2<. | CHNGHOW3>0 & CHNGHOW3<. | CHNGHOW4>0 & CHNGHOW4<. | CHNGHOW5>0 & CHNGHOW5<. | CHNGHOW6>0 & CHNGHOW6<. | CHNGHOW7>0 & CHNGHOW7<. | CHNGHOW8>0 & CHNGHOW8<. | CHNGHOW9>0 & CHNGHOW9<. | CHNGHOW10>0 & CHNGHOW10<. | CHNGHOW11>0 & CHNGHOW11<. | CHNGHOW12>0 & CHNGHOW12<. 
replace SPENDCHG`i'=1 if CHNGHOW`i'==1

}

label variable SPENDCHG1 "more purchases online"
label variable SPENDCHG2 "more curbside pickup"
label variable SPENDCHG3 "more in-store purchases"
label variable SPENDCHG4 "increased use of credit cards"
label variable SPENDCHG5 "increased use of cash"
label variable SPENDCHG6 "avoid eating at restaurants"
label variable SPENDCHG7 "resumed eating at restaurants"
label variable SPENDCHG8 "cancelled in-person med/dent appt"
label variable SPENDCHG9 "attended in-person med/dent appt"
label variable SPENDCHG10 "cancelled housekeeping/care services"
label variable SPENDCHG11 "resumed/new housekeeping/care services"
label variable SPENDCHG12 "made no changes"

forvalues i=1/13 {

g WHYSPENDCHG`i'=0 if WHYCHNGD1>0 & WHYCHNGD1<. | WHYCHNGD2>0 & WHYCHNGD2<. | WHYCHNGD3>0 & WHYCHNGD3<. | WHYCHNGD4>0 & WHYCHNGD4<. | WHYCHNGD5>0 & WHYCHNGD5<. | WHYCHNGD6>0 & WHYCHNGD6<. | WHYCHNGD7>0 & WHYCHNGD7<. | WHYCHNGD8>0 & WHYCHNGD8<. | WHYCHNGD9>0 & WHYCHNGD9<. | WHYCHNGD10>0 & WHYCHNGD10<. | WHYCHNGD11>0 & WHYCHNGD11<. | WHYCHNGD12>0 & WHYCHNGD12<. | WHYCHNGD13>0 & WHYCHNGD13<. 
replace WHYSPENDCHG`i'=1 if WHYCHNGD`i'==1 

}  

label var WHYSPENDCHG11 "concerns abt economy"
label var WHYSPENDCHG7 "concern abt layoff"
label var WHYSPENDCHG5 "loss of income"
label var WHYSPENDCHG6 "income gain"
label var WHYSPENDCHG8 "no concern abt layoff"
label var WHYSPENDCHG12 "no concern abt economy"

*/


g DELAYHC=0 if DELAY>0 & DELAY<. | NOTGET>0 & DELAY<.
replace DELAYHC=1 if DELAY==1 | NOTGET==1

label define delayhc 0 "did not delay hc" 1 "delayed/didn't get hc b/c of covid"
label values DELAYHC delayhc
label variable DELAYHC "delayed/didn't get hc b/c of covid"

g SKIPHC=0 if DELAY>0 & DELAY<. & WEEK>=13 | NOTGET>0 & NOTGET<. & WEEK>=13 
replace SKIPHC=1 if DELAY==1 & WEEK>=13 | NOTGET==1 & WEEK>=13
label define skiphc 0 "did not skip hc" 1 "delayed/didn't get health care"

g MHNOTGET=0 if MH_NOTGET<. & MH_NOTGET>0
replace MHNOTGET=1 if MH_NOTGET==1
label variable MHNOTGET "needed MH services, bud didn't get it"

foreach inf in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 {
	
g INFLRESP`inf'=0 if PRICECOPE1==1 | PRICECOPE2==1 | PRICECOPE3==1 | PRICECOPE4==1 | PRICECOPE5==1 | PRICECOPE6==1 | PRICECOPE7==1 | PRICECOPE8==1 | PRICECOPE9==1 | PRICECOPE10==1 | PRICECOPE11==1 | PRICECOPE12==1 | PRICECOPE13==1 | PRICECOPE14==1 | PRICECOPE15==1 | PRICECOPE16==1 | PRICECOPE17==1 | PRICECOPE18==1 | PRICECOPE19==1
replace INFLRESP`inf'=1 if PRICECOPE`inf'==1
	
}

label var INFLRESP1 "shop at stores with lower prices"
label var INFLRESP2 "switch to generic brands"
label var INFLRESP3 "purchase less produce or meat"
label var INFLRESP4 "go out less to eat or order fewer deliveries"
label var INFLRESP5 "cancel/reduce subscription service"
label var INFLRESP6 "cancel/reduce plans to attend events"
label var INFLRESP7 "drive less/change mode of transportation"
label var INFLRESP8 "delay major purchases"
label var INFLRESP9 "delay medical care"
label var INFLRESP10 "work additional jobs"
label var INFLRESP11 "save less"
label var INFLRESP12 "use more debt"
label var INFLRESP13 "less utilities"
label var INFLRESP14 "move to less expensive housing"
label var INFLRESP15 "ask friends of family for help"
label var INFLRESP16 "change/reduce childcare"
label var INFLRESP17 "benefits from charities"
label var INFLRESP18 "other"
label var INFLRESP19 "no change"

egen NOINFRESP=rowtotal(INFLRESP1-INFLRESP18)

g NOINFLRESP=0 if PRICECOPE1==1 | PRICECOPE2==1 | PRICECOPE3==1 | PRICECOPE4==1 | PRICECOPE5==1 | PRICECOPE6==1 | PRICECOPE7==1 | PRICECOPE8==1 | PRICECOPE9==1 | PRICECOPE10==1 | PRICECOPE11==1 | PRICECOPE12==1 | PRICECOPE13==1 | PRICECOPE14==1 | PRICECOPE15==1 | PRICECOPE16==1 | PRICECOPE17==1 | PRICECOPE18==1 | PRICECOPE19==1
replace NOINFLRESP=NOINFRESP if NOINFLRESP<.
label var NOINFLRESP "count of inflation responses"

*** 		STIMULUS USE AND SPENDING SOURCES						***
***			DATA SHOW CLEAR BREAK WITH WEEK 28 						***

g EIPRECEIPT=0 if inlist(EIP, 1, 2, 3, 4) & WEEK<=27 | inlist(EIP_YN, 1, 2) & WEEK>=28
replace EIPRECEIPT=1 if inlist(EIP, 1, 2, 3) & WEEK<=27 | EIP_YN==1 & WEEK>=28

g EIPRECEIPT2=0 if inlist(EIP, 1, 2, 3, 4) & WEEK<=27 | inlist(EIP_YN, 1, 2) & WEEK>=28
replace EIPRECEIPT2=1 if EIP==1 & WEEK<=27 | EIPRV==1 & WEEK>=28 
replace EIPRECEIPT2=2 if EIP==2 & WEEK<=27 | EIPRV==2 & WEEK>=28
replace EIPRECEIPT2=3 if EIP==3 & WEEK<=27 | EIPRV==3 & WEEK>=28
replace EIPRECEIPT2=4 if EIP==4 & WEEK<=27 | EIP_YN==2 & WEEK>=28
label define eipreceipt 0 "n.e.c." 1 "mostly spend" 2 "mostly save" 3 "pay down debt" 4 "did not receive EIP"
label values EIPRECEIPT2 eipreceipt
label variable EIPRECEIPT2 "uses of EIP"

g SPENDEIP=(EIPRECEIPT2==1)
g SAVEEIP=(EIPRECEIPT2==2)
g DEBTEIP=(EIPRECEIPT2==3)
g NOEIP=(EIPRECEIPT2==4)

*** 	CHILD CARE AND CHILD TAX CREDIT RECEIPT							***

g CHILDCAREIMPACT=0 if inlist(CHLDCARE, 1, 2) 
replace CHILDCAREIMPACT=1 if CHLDCARE==1

foreach cc in 1 2 3 4 5 6 7 8 9 {
	
g CCIMPACT`cc'=0 if CHILDCAREIMPACT==1
replace CCIMPACT`cc'=1 if CHLDIMPCT`cc'==1
	
}

label variable CCIMPACT1 "used unpaid leave for childcare"
label variable CCIMPACT2 "used paid leave for childcare"
label variable CCIMPACT3 "cut hours for childcare"
label variable CCIMPACT4 "left job for childcare"
label variable CCIMPACT5 "lost job b/c childcare"
label variable CCIMPACT6 "did not look for job b/c childcare"
label variable CCIMPACT7 "supervised kids while working"
label variable CCIMPACT8 "other impacts b/c of childcare"
label variable CCIMPACT9 "none of the above b/c of childcare"

g LESSWORKCHILDCARE=0 if CHILDCAREIMPACT==1
replace LESSWORKCHILDCARE=1 if CCIMPACT1==1 | CCIMPACT2==1 | CCIMPACT3==1 | CCIMPACT4==1 | CCIMPACT5==1
label variable LESSWORKCHILDCARE "worked less voluntarily/involuntarily b/c of child care impact"

g CTCRECEIPT=0 if inlist(CTC_YN, 1, 2)
replace CTCRECEIPT=1 if CTC_YN==1
label variable CTCRECEIPT "receive advance CTC payments"

g CTCUSE=0 if inlist(CTC_USE, 1, 2, 3)
replace CTCUSE=1 if CTC_USE==1
replace CTCUSE=2 if CTC_USE==2
replace CTCUSE=3 if CTC_USE==3
label define ctcuse 0 "n.e.c" 1 "mostly spend" 2 "mostly save" 3 "mostly pay down debt"
label values CTCUSE ctcuse
label variable CTCUSE "uses of CTC"

g CTCSPEND=0 if inlist(CTC_USE, 1, 2, 3)
replace CTCSPEND=1 if CTC_USE==1
label variable CTCSPEND "mainly spent CTC"

g CTCSAVE=0 if inlist(CTC_USE, 1, 2, 3)
replace CTCSAVE=1 if CTC_USE==2
label variable CTCSAVE "mainly saved CTC"

g CTCDEBT=0 if inlist(CTC_USE, 1, 2, 3)
replace CTCDEBT=1 if CTC_USE==3
label variable CTCDEBT "mainly paid down debt with CTC"

g CTCSPEND1=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND1=1 if CTCSPND1==1 | CTCSPND2==1 //* food and clothing
g CTCSPEND2=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND2=1 if CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 //* school & child care
g CTCSPEND3=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND3=1 if CTCSPND9==1 //* recreational goods
g CTCSPEND4=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND4=1 if CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 //* housing and utilities
g CTCSPEND5=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND5=1 if CTCSPND13==1 | CTCSPND14==1 //* loans
g CTCSPEND6=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND6=1 if CTCSPND15==1 //* donations
g CTCSPEND7=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND7=1 if CTCSPND16==1 //* savings and investment
g CTCSPEND8=0 if CTCSPND1==1 | CTCSPND2==1 | CTCSPND3==1 | CTCSPND4==1 | CTCSPND5==1 | CTCSPND6==1 | CTCSPND7==1 | CTCSPND8==1 | CTCSPND9==1 | CTCSPND10==1 | CTCSPND11==1 | CTCSPND12==1 | CTCSPND13==1 | CTCSPND14==1 | CTCSPND15==1 | CTCSPND16==1 | CTCSPND17==1
replace CTCSPEND8=1 if CTCSPND17==1 //* other
label variable CTCSPEND1 "CTC spending, food clothing"
label variable CTCSPEND2 "CTC spend, school & childcare"
label variable CTCSPEND3 "CTC spend, recreational goods"
label variable CTCSPEND4 "CTC spend, housing & utilities"
label variable CTCSPEND5 "CTC spend, loans"
label variable CTCSPEND6 "CTC spend, donations"
label variable CTCSPEND7 "CTC spend, savings & investment"
label variable CTCSPEND8 "CTC spend, other"

g CTCTIMER=0 if inlist(month, 17, 18, 19, 20)
replace CTCTIMER=1 if inlist(month, 19, 20)
label define ctctime 0 "two months before expanded CTC checks" 1 "two months after expanded CTC checks"
label value CTCTIMER ctctime
label variable CTCTIMER "indicator two months before/after CTC checks started"

g CTCTIMER2=0 if inlist(month, 19, 20, 21, 22)
replace CTCTIMER2=1 if inlist(month, 21, 22)
label define ctctimer2 0 "first two months of CTC checks" 1 "second two months of CTC checks"
label value CTCTIMER2 ctctimer2
label variable CTCTIMER2 "indicator for early and later months of CTC checks"

*** 	SEPARATE APPROACH TO EIP USES, NOT USED -- QUESTIONS CHANGED 		***
*** 	IN LATER PHASES, TOO; NOT UPDATED TO INCLUDED THOSE PHASES			***

g EIPUSES=0 if EIP~=4 & EIP~=-88 & EIP~=-99 & EIP<. & WEEK<=27  
replace EIPUSES=1 if EIPSPND1==1 | EIPSPND2==1 | EIPSPND3==1 | EIPSPND4==1 | EIPSPND5==1 | EIPSPND6==1 | EIPSPND8==1
replace EIPUSES=2 if EIPSPND7==1 | EIPSPND9==1 | EIPSPND10==1
replace EIPUSES=3 if EIPSPND11==1
replace EIPUSES=4 if EIPSPND12==1
replace EIPUSES=5 if EIPSPND13==1

label define eipuses 0 "n.e.c." 1 "expenses" 2 "paying down debt" 3 "charity" 4 "saving/investment" 5 "other"
label values EIPUSES eipuses
label variable EIPUSES "Broad EIP spending categories" //** defined slightly differently than EIP

label define eip 1 "Mostly to pay for expenses (food, clothing, shelter, etc.)" 2 "Mostly to pay off debt (car loans, student loans, credit cards)" 3 "Mostly to add to savings" 4 "Not applicable, I did not and do not expect to receive the stimulus payment" -99 "Question seen but category not selected" -88 "Missing / Did not report"
label values EIP eip
label variable EIP "Census defined EIP spending categories"

*** 	EIPUSES DEFINED CONDITIONAL ON HAVING GOTTEN PAYMENTS			***
***		VARIABLE DEFINITIONS CONSISTENT THEN ACROSS PHASES OF HPS 		***

g EIPSPEND=0 if inlist(EIP, 1, 2, 3) | inlist(EIPRV, 1, 2, 3)
replace EIPSPEND=1 if EIP==1 | EIPRV==1

g EIPSAVE=0 if inlist(EIP, 1, 2, 3) | inlist(EIPRV, 1, 2, 3)
replace EIPSAVE=1 if inlist(EIP, 2) | EIPRV==2

g EIPDEBT=0 if inlist(EIP, 1, 2, 3) | inlist(EIPRV, 1, 2, 3)
replace EIPDEBT=1 if inlist(EIP, 3) | EIPRV==3

g EIPSAVE2=0 if inlist(EIP, 1, 2, 3) 
replace EIPSAVE2=1 if inlist(EIPUSES, 4)

g EIPSPEND2=0 if inlist(EIP, 1,2,3)
replace EIPSPEND2=1 if inlist(EIPUSES, 1, 3, 5)

g EIPDEBT2=0 if inlist(EIP, 1,2,3)
replace EIPDEBT2=1 if inlist(EIPUSES, 2)

g EIPUSE=0 if inlist(EIP, 1, 2, 3) | inlist(EIPRV, 1, 2, 3)
replace EIPUSE=1 if EIP==1 | EIPRV==1
replace EIPUSE=2 if EIP==2 | EIPRV==2
replace EIPUSE=3 if EIP==3 | EIPRV==3

label define eipuse 0 "n.e.c." 1 "mostly spend" 2 "mostly save" 3 "mostly pay down debt"
label values EIPUSE eipuse
label variable EIPUSE "broad EIP uses"

*** 		SPENDING SOURCES 										***

foreach num in 1 2 3 4 5 {

*** THIS DEFINITION IS THE SAME AS THE ONE USED BY THE CENSUS 		***

g SOURCESPEND`num'=0 if SPNDSRC`num'~=-88 & SPNDSRC`num'<. | SPND_SRC`num'~=-88 & SPND_SRC`num'<. | SPND_SRCRV`num'~=-88 & SPND_SRCRV`num'<.
replace SOURCESPEND`num'=1 if SPNDSRC`num'==1 | SPND_SRC`num'==1 | SPND_SRCRV`num'==1

}

g SOURCESPEND6=0 if SPNDSRC6~=-88 & SPNDSRC6<. | SPND_SRC6~=-88 & SPND_SRC6<. 
replace SOURCESPEND6=1 if SPNDSRC6==1 | SPND_SRC6==1

g SOURCESPEND7=0 if SPNDSRC7~=-88 & SPNDSRC7<. | SPND_SRC7~=-88 & SPND_SRC7<. | SPND_SRCRV6~=-88 & SPND_SRCRV6<.
replace SOURCESPEND6=1 if SPNDSRC7==1 | SPND_SRC7==1 | SPND_SRCRV6==1

g SOURCESPEND8=0 if SPND_SRC7~=-88 & SPND_SRC7<.
replace SOURCESPEND8=1 if SPND_SRC7==1

g SOURCESPEND9=0 if SPNDSRC8~=-88 & SPNDSRC8<. | SPND_SRC9~=-88 & SPND_SRC9<. | SPND_SRCRV7~=-88 & SPND_SRCRV7<.
replace SOURCESPEND9=1 if SPNDSRC8==1 | SPND_SRC9==1 | SPND_SRCRV7==1

g SOURCESPEND10=0 if SPND_SRC10~=-88 & SPND_SRC10<. | SPND_SRCRV9~=-88 & SPND_SRCRV9<.
replace SOURCESPEND9=1 if SPND_SRC10==1 | SPND_SRCRV9==1

g SOURCESPEND11=0 if SPND_SRC11~=-88 & SPND_SRC11<. | SPND_SRCRV10~=-88 & SPND_SRCRV10<.
replace SOURCESPEND9=1 if SPND_SRC11==1 | SPND_SRCRV10==1

g SOURCESPEND12=0 if SPND_SRC12~=-88 & SPND_SRC12<. | SPND_SRCRV11~=-88 & SPND_SRCRV11<.
replace SOURCESPEND9=1 if SPND_SRC12==1 | SPND_SRCRV11==1

g SOURCESPEND13=0 if SPND_SRCRV8~=-88 & SPND_SRCRV8<.
replace SOURCESPEND13=1 if SPND_SRCRV8==1

label variable SOURCESPEND1 "income for expenses"
label variable SOURCESPEND2 "credit cards for expenses"
label variable SOURCESPEND3 "savings for expenses"
label variable SOURCESPEND4 "borrowing from friends/family for exp."
label variable SOURCESPEND5 "UI for expenses"
label variable SOURCESPEND6 "EIP for expenses stops w/phase 3.6"
label variable SOURCESPEND7 "deferred payments for expenses"
label variable SOURCESPEND8 "CTC payments for expenses"
label variable SOURCESPEND9 "SNAP payments for expenses"
label variable SOURCESPEND10 "EBT payments for expenses"
label variable SOURCESPEND11 "rental assistance for expenses"
label variable SOURCESPEND12 "other sources for expenses"
label variable SOURCESPEND13 "WIC payments for expenses"

*** 	CHILDCARE VARIABLES, STARTING WITH WEEK 49 		***

foreach cc in 1 2 3 4 5 6 7 8 {
	
g KIDCARE`cc'=0 if CCARETYP1<. | CCARETYP2<. | CCARETYP3<. | CCARETYP4<. | CCARETYP5<. | CCARETYP6<. | CCARETYP7<. | CCARETYP8<.
replace KIDCARE`cc'=1 if CCARETYP`cc'==1
	
}

egen KIDCARESOURCES=rowtotal(KIDCARE1 KIDCARE2 KIDCARE3 KIDCARE4 KIDCARE5 KIDCARE6 KIDCARE7 KIDCARE8)

g CCARE_NOPAY=0 if CCARETYP1<. | CCARETYP2<. | CCARETYP3<. | CCARETYP4<. | CCARETYP5<. | CCARETYP6<. | CCARETYP7<. | CCARETYP8<.
replace CCARE_NOPAY=1 if CCARETYP6==1 | CCARETYP7==1

g CCARE_NOPAY_ONLY=0 if CCARETYP1<. | CCARETYP2<. | CCARETYP3<. | CCARETYP4<. | CCARETYP5<. | CCARETYP6<. | CCARETYP7<. | CCARETYP8<.
replace CCARE_NOPAY_ONLY=1 if CCARE_NOPAY==1 & CCARETYP6==1 & CCARETYP7==1 & inlist(KIDCARESOURCES, 1, 2) | CCARE_NOPAY==1 & CCARETYP6==1 & KIDCARESOURCES==1 | CCARE_NOPAY==1 & CCARETYP7==1 & KIDCARESOURCES==1 

save "PULSE_complete.dta", replace
